import request from '@/utils/request'

/**
 * 获取菜单列表
 * @returns 菜单列表
 */
export const getMenuListAPI = () => {
  return request({
    url: `/menus`
  })
}

/**
 * 删除菜单
 * @param {String} delId 菜单id
 * @returns 删除结果
 */
export const delMenuAPI = (delId) => {
  return request({
    url: `/menus/${delId}`,
    method: 'DELETE'
  })
}

/**
 * 添加菜单
 * @param {Object} menu 菜单数据
 * @returns 添加结果
 */
export const addMenusAPI = (menu) => {
  return request({
    url: '/menus',
    data: menu,
    method: 'POST'
  })
}

/**
 * 获取菜单详情
 * @param {Object} menuData 菜单数据
 * @returns 菜单详情
 */
export const getMenuInfoAPI = (menuData) => {
  return request({
    url: `/menus/${menuData.id}`,
    params: menuData
  })
}

/**
 * 修改菜单
 * @param {Object} menuData 菜单对象
 * @returns 修改结果
 */
export const resetMenuAPI = (menuData) => {
  return request({
    url: `/menus/${menuData.id}`,
    data: menuData,
    method: 'PUT'
  })
}
